package ots.cms.chapter3.controler;

import java.io.IOException;
import java.util.ArrayList;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import ots.cms.chapter3.model.BeerExpert;

public class SelectBeer extends HttpServlet {

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doPost(request, response);
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String input = request.getParameter("color");
		
		BeerExpert be = new BeerExpert();
		ArrayList<String> list = be.getBrands(input);
		
		request.setAttribute("list", list);
		response.encodeURL("/chapter3/result.jsp");
		RequestDispatcher view = request.getRequestDispatcher("/chapter3/result.jsp");
		view.forward(request, response);
	}
}
